<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/global.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>>广东石油化工学院学生信息管理系统</title>
    <link rel="stylesheet" href="${path}/static/js/layui/css/layui.css">
    <link rel="stylesheet" href="${path}/static/css/index.css">
    <link rel="shortcut icon" href="${path}/static/images/title/42496school_99040.ico" type="image/x-icon">

</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header layui-bg-cyan">
        <div class="layui-logo title">
            <a href="" style="color: #009688;">广东石油化工学院学生信息管理系统</a>
        </div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="${path}/static/images/user/${user.imgurl}" class="layui-nav-img">

                    <c:choose>
                        <c:when test="${user.role == 1}">
                            ${user.username}同学
                        </c:when>
                        <c:when test="${user.role == 2}">
                           ${user.username}老师
                        </c:when>
                        <c:otherwise>
                        </c:otherwise>
                    </c:choose>

                </a>
            </li>
            <li class="layui-nav-item"><a href="${path}/user/logout">退出</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-cyan">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree layui-bg-cyan">
                <c:if test="${user.role == 1}">
                    <li class="layui-nav-item">
                        <a class="" href="javascript:;"><i class="layui-icon layui-icon-user"></i>&nbsp;&nbsp;我的基本信息</a>
                        <dl class="layui-nav-child">
                            <dd><a href="${path}/common/user-info.jsp" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1" ></i>&nbsp;&nbsp;个人信息</a>
                            </dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item">
                        <a class="" href="javascript:;"><i class="layui-icon layui-icon-template-1"></i>&nbsp;&nbsp;我的课程信息</a>
                        <dl class="layui-nav-child">
                            <dd><a href="javascript:void(0)" target="myIframe" id="getCourse"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;初始化课程信息</a></dd>
                            <dd><a href="${path}/user/getAllCourse?zhouci=12" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;我的课表</a>
                            </dd>
                            <dd><a href="${path}/user/getMyGrade" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;我的成绩</a>
                            </dd>
                        </dl>
                    </li>

                </c:if>
                <c:if test="${user.role == 2}">
                    <li class="layui-nav-item">
                        <a href="javascript:;"><i class="layui-icon layui-icon-group"></i>&nbsp;&nbsp;我的信息</a>
                        <dl class="layui-nav-child">
                            <dd><a href="${path}/common/user-info.jsp" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;个人信息</a>
                            </dd>
                        </dl>
                    </li>

                    <li class="layui-nav-item">
                        <a class="" href="javascript:;"><i class="layui-icon layui-icon-template-1"></i>&nbsp;&nbsp;我的课程信息</a>
                        <dl class="layui-nav-child">
                            <dd><a href="${path}/user/getTeacherTask" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;上课任务</a>
                            </dd>
                            <dd><a href="${path}/user/getCourseAndStudent" target="myIframe" layui-icon-template-1><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;批改成绩</a>
                            </dd>
                        </dl>
                    </li>
                </c:if>
                <c:if test="${user.role == 0}">
                    <li class="layui-nav-item"><a href="javascript:;"><i
                            class="layui-icon layui-icon-read"></i>&nbsp;&nbsp;组织机构</a>
                        <dl class="layui-nav-child">
                            <dd><a href="${path}/college/listCollege" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;院系管理</a></dd>
                            <dd><a href="${path}/major/listMajor" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;专业管理</a></dd>
                            <dd><a href="${path}/grade/listGrade" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;班级管理</a></dd>
                            <dd><a href="${path}/courseType/listCourseType" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;课程分类</a></dd>
                        </dl>
                    </li>

                    <li class="layui-nav-item"><a href="javascript:;"><i
                            class="layui-icon layui-icon-set-fill"></i>&nbsp;&nbsp;管理员</a>
                        <dl class="layui-nav-child">
                            <dd><a href="${path}/admin/getAllStudents" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;学生管理</a>
                            </dd>
                            <dd><a href="${path}/admin/getAllTeachers" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;教师管理</a>
                            </dd>
                            <dd><a href="${path}/admin/getAllCourses" target="myIframe"><i
                                    class="layui-icon layui-icon-add-1"></i>&nbsp;&nbsp;课程管理</a>
                            </dd>
                        </dl>
                    </li>
                </c:if>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <iframe src="${path}/welcome.jsp" width="100%" height="100%" name="myIframe" scrolling="auto" class="iframe"
                framborder="0"></iframe>
    </div>



    <div class="layui-footer">
        <!-- 底部固定区域 -->
        Copyright 2021-2022 by XMC
    </div>
</div>
<script src="${path}/static/js/layui/layui.js"></script>
<script>
    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;
        var $ = layui.jquery;
        $("#getCourse").on('click',function (){
            $.ajax({
                type:"post",
                url:"${path}/user/getCourse",
                contentType: 'application/json; charset=UTF-8',
                beforeSend:function(){
                    //显示正在加载数据
                    loadIndex = layer.msg('课程表初始化中，请稍候...', {icon: 16,time:20*1000});
                },
                success:function (data) {
                    layer.close(loadIndex);
                    if (data.success) {
                        layer.msg("初始化成功!" ,{offset: '60px',icon: 6,anim: 6,time: 5000});
                    }else{
                        layer.alert('请求失败,请检查学校服务器是否开启!');
                    }

                },
                error: function (res) {
                    layer.alert('请求失败,请检查学校服务器是否开启!');
                }
            })
        })
    })
</script>
</body>
</html>